<template>
	<view class="content" style="background-color: green;margin-top: 50rpx;">
		<view class="title"style="font-size: 50rpx;">子组件B</view>
		<view class="b-box" style="margin-bottom: 30rpx;">
			<text>ComA组件传进来的值:</text>
			<text class="intent-text-box" style="background-color: blue;">{{result}}</text>
		</view>
		<view class="b-box" style="margin: 10rpx;display: flex; align-content: center; justify-content: space-between;">
			<text>回传值:</text>
			<input type="text" v-model="callbackValue" style="color: yellow;background-color: darkgray;" />
			<button @click="sendOutside()" size="mini" style="width: 20%;">回传</button>
		</view>
	</view>
</template>

<script>
	export default {
		name: "comB",
		data() {
			return {
				callbackValue:"user",
				result:""

			};
		},
		created() {
			console.log("comB created");
			uni.$on('SendIntent',(msg)=>{
				console.log("SendIntent--comB get Intent" + msg);
				this.result = msg
			})
		},
		mounted() {
			console.log("comB---mounted");
		},
		methods:{
			sendOutside(){
				console.log("huichuan----"+ this.callbackValue);
				this.$emit('callBackFun',this.callbackValue);
			}
		}
	}
</script>

<style>
.content{
	height: 120px;
	width: 90%;
	margin: 50rpx auto;
}
</style>